import java.util.*;

public class Main{
        public static boolean chkParenthesis(String A, int n) {
            // write code here
            if (n % 2 != 0) {
                return false;
            }
            Stack<Character> stack = new Stack<>(); //创建一个栈，为左括号就入栈，为右括号则判断栈顶元素是否为左括号
           for(char ch:A.toCharArray()) {
               if(ch == '(') {
                   stack.push(ch);
               }else if (ch == ')') {
                   //右括号先于左括号出现，为非法
                   if(stack.isEmpty()) {
                       return false;
                   }
                   //括匹配则出栈顶元素
                   else if(stack.peek() == '(') {
                          stack.pop();
                   }
               }else {
                   return false;
               }
           }
           return stack.isEmpty();
        }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int len = s.length();
        boolean ret = chkParenthesis(s,len);
        System.out.println(ret);
    }
}